package priv.ljh.operate.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import priv.ljh.operate.mapper.BookMapper;
import priv.ljh.operate.service.BookService;

import java.util.Date;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    BookMapper bookMapper;
    @Override
    public int insertBook(String title, int stock_quantity, String market_price, String sell_price) {
        Date add_time=  new Date();
        int x = (int) (Math.random()*100+100);
        String good_no="SD"+String.valueOf(x);
        return bookMapper.insertBook(title,add_time,good_no,stock_quantity,market_price,sell_price);
    }

    @Override
    public int insertBookInfo(String title, int stock_quantity, String market_price, String sell_price) {
        Date add_time=  new Date();
        String zhaiyao="这是一个很好的商品";
        int click=11;
        String img_url="https://img1.doubanio.com/view/subject/l/public/s27249387.jpg";

        return bookMapper.insertBookInfo(title,add_time,zhaiyao,click,img_url,stock_quantity,market_price,sell_price);
    }

    @Override
    public int insertDesc(String title) {
        String content="这是一个很好的商品";
        return bookMapper.insertDesc(title,content);
    }

    @Override
    public int insertImagesplus() {
        String src1="https://img1.doubanio.com/view/subject/l/public/s27249387.jpg";
        String src2="https://img3.doubanio.com/view/subject/l/public/s16843580.jpg";
        return bookMapper.insertImagesplus(src1,src2);
    }


}
